# frozen_string_literal: true

# Here is the 'helloworld' action
namespace '/setup' do
  helpers ApiHelpers
  before do
    auth_gate
    inject_params
  end
  post '/system' do
    puts 'hello system'
    puts @json_params
    config = Config.find_or_create_by(name: 'default')
    config.page_size = @json_params[:page_size]
    config.save!
    'system'
  end

  get '/system' do
    puts 'get system'
    config = Config.find_by(name: 'default')
    ap config
    {
      code: 'ok',
      payload: {
        config: config
      }
    }.to_json
  end
end
